package DesignPattern.CommandPattern;

// 具体的减法命令
public class SubtractCommand implements Command {
    private Calculator calculator;
    private int operand;

    public SubtractCommand(Calculator calculator, int operand) {
        this.calculator = calculator;
        this.operand = operand;
    }

    @Override
    public void execute() {
        calculator.subtract(operand);
    }

    @Override
    public void undo() {
        calculator.add(operand);
    }
}